<%-- 
    Document   : commupdate
    Created on : 2014/2/24, 下午 04:43:07
    Author     : Gjun
--%>

<%@page import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String id = request.getParameter("id");
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    java.sql.Connection con = DriverManager.getConnection("jdbc:sqlserver://10.10.3.14:1433;databaseName=javadb", "javadb", "java");
    java.sql.Statement st = con.createStatement();      
    String sql="SELECT * FROM 產品維護 WHERE id="+id;
    java.sql.ResultSet rs = st.executeQuery(sql);
    
    %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <img src="productPic/<%=id%>.png">
        <form action ="UploadServlet" method="post" enctype="multipart/form-data"> 
            <input type="hidden" name="id" value=<%=id%>>
   修改圖片: <input type="file" name="file" size="20" maxlength="20" > <br>
            
            <input type="submit" value="上傳" >
      </form>
        <%
        
        if(rs.next())
        {
            String 產品名稱 = rs.getString("產品名稱");
            String 產品價格 = rs.getString("產品價格");
            String 庫存量 = rs.getString("庫存量");
            String 產品介紹 = rs.getString("產品介紹");
            %>
            
            <form action="commupdate2.jsp" method="post">
                產品名稱: <input type="text" name="產品名稱" value="<%= 產品名稱 %>"> <br>
                產品價格: <input type="text" name="產品價格" value="<%= 產品價格 %>"> <br>
                庫存量: <input type="text" name="庫存量" value="<%= 庫存量 %>"> <br>
                產品介紹: <input type="text" name="產品介紹" value="<%= 產品介紹 %>"> <br>
                <input type="hidden" name="id" value="<%= id %>">
            <input type="submit" value="更新">
            </form>
            
            <form action="delete.jsp" method="post">
                <input type="hidden" name="id" value="<%= id %>">
                <input type="submit" value="刪除">
            </form>
                <form action="listdb.jsp">
                <input type="submit" value="返回清單">
            </form>
            
            
            <%
        }
        else
        {
            out.println("這筆資料不存在!");
        }
    
        %>
    </body>
</html>
